#header{
<!--'纵有三千弱水 ',
		'阡陌繁花',
		'怎敌你拈花一笑'-->

}# #body{
<div class="layui-row" style="margin-top: 10px;">
	<div class="layui-col-xs12">
		<div class="mui-content" id="tie">

		</div>
		<div id="demo3"></div>
	</div>
</div>
<div class="layui-row" style="margin-top: 10px;">
	<div class="layui-col-xs12">
		<form class="layui-form layui-form-pane" lay-filter="form">
			<div class="layui-form-item">
				<div class="">
					<input type="text" name="title" autocomplete="off" placeholder="请输入标题" class="layui-input" lay-verify="title">
				</div>
			</div>

			<div class="layui-form-item layui-form-text">

				<div class="layui-input-block">
					<textarea class="layui-textarea layui-hide" name="msg" lay-verify="content" id="LAY_demo_editor"></textarea>
				</div>
			</div>
			<div class="layui-form-item">
				<button class="layui-btn" lay-submit="" lay-filter="form0">发表</button>
			</div>
		</form>

	</div>
</div>

}# #footer{
<!--script-->
<script type="text/html" id='temp2'>
	<ul class="mui-table-view mui-table-view-striped mui-table-view-condensed">
		{%each(i,dt) result%}
		<a href='!!SplitUrl("homepage/home/page")!!&para=${Id}'>
			<li class="mui-table-view-cell">
				<div class="mui-table">
					<div class="mui-table-cell mui-col-xs-10">
						<h4 class="mui-ellipsis">${title}</h4>
						<h5>楼主：${nickname}</h5>
						<p class="mui-h6 mui-ellipsis"></p>
					</div>
					<div class="mui-table-cell mui-col-xs-2 mui-text-right">
						<span class="mui-h5">${time}</span>
					</div>
				</div>
			</li>
		</a>
		{%/each%}
	</ul>
</script>
<script>
	function tieDt() {
		post('!!SplitUrl("homepage/column/tie_json")!!', {}, function(dt) {

			$('#temp2').tmpl(dt).appendF('#tie');

		}, true)

	}
	tieDt()

	layui.use(['laypage', 'layer'], function() {
		var laypage = layui.laypage
		//自定义首页、尾页、上一页、下一页文本
		laypage.render({
			elem: 'demo3',
			count: 100,
			first: '首页',
			last: '尾页',
			prev: '<em>←</em>',
			next: '<em>→</em>',
			jump: function(obj, first) {
				//obj包含了当前分页的所有参数，比如：
				console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
				console.log(obj.limit); //得到每页显示的条数

				//首次不执行
				if(!first) {
					//do something
				}
			}
		});

	});

	layui.use(['form', 'layedit', 'laydate'], function() {
		var form = layui.form,
			layer = layui.layer,
			layedit = layui.layedit,
			laydate = layui.laydate;

		layedit.set({
			uploadImage: {

				url: '!!SplitUrl("homepage/column/tieEditUp/")!!', //接口url
				type: 'post' //默认post
			}
		});
		//注意：layedit.set 一定要放在 build 前面，否则配置全局接口将无效。

		//创建一个编辑器
		var editIndex = layedit.build('LAY_demo_editor');

		//表单初始赋值
		form.val('form', {
			"title": "",
			"msg": ""

		})
		//自定义验证规则
		form.verify({
			title: function(value) {
				if(value.length < 3) {
					return '标题至少得3个字符啊';
				}
			},
			content: function(value) {
				value = layedit.getContent(editIndex)
				console.log(value)
				if(value.length < 3) {
					return '内容至少得3个字符啊';
				}
				layedit.sync(editIndex);
			}
		});

		//监听提交
		form.on('submit(form0)', function(data) {
			delete data.field.file;
			//				layer.alert(JSON.stringify(data.field), {
			//					title: '最终的提交信息'
			//				})
			post('!!SplitUrl("homepage/column/tieupdate/")!!', data.field, function(x) {
				if(x.status)
				{	
					
					tieDt()
					$('[name=title]').val('')
					$('#LAY_layedit_1').contents().find('body').html('')
				}
				
				else
					layer.alert(x.result);
			}, true)

			return false;
		});

	});
</script>
}#